home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / styles / paragraphstyle.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-02-06  |  5.8 KB  |  167 lines

  1. /*
  2.  For general Scribus (>=1.3.2) copyright and licensing information please refer
  3.  to the COPYING file provided with the program. Following this notice may exist
  4.  a copyright and/or license notice that predates the release of Scribus 1.3.2
  5.  for which a new license (GPL+exception) is in place.
  6.  */
  7. /***************************************************************************
  8. *                                                                         *
  9. *   This program is free software; you can redistribute it and/or modify  *
  10. *   it under the terms of the GNU General Public License as published by  *
  11. *   the Free Software Foundation; either version 2 of the License, or     *
  12. *   (at your option) any later version.                                   *
  13. *                                                                         *
  14. ***************************************************************************/
  15.  
  16. #ifndef PARAGRAPHSTYLE_H
  17. #define PARAGRAPHSTYLE_H
  18.  
  19. #include "style.h"
  20. #include "charstyle.h"
  21. #include "styles/stylecontextproxy.h"
  22.  
  23.  
  24. class ResourceCollection;
  25.  
  26.  
  27. class SCRIBUS_API ParagraphStyle : public Style
  28. {
  29. public:
  30.     enum LineSpacingMode { 
  31.         FixedLineSpacing        = 0, 
  32.         AutomaticLineSpacing    = 1,
  33.         BaselineGridLineSpacing = 2
  34.     };
  35.     enum AlignmentType {
  36.         Leftaligned  = 0,
  37.         Centered     = 1,
  38.         Rightaligned = 2,
  39.         Justified    = 3,
  40.         Extended     = 4
  41.     };
  42.     enum OpticalMarginType {
  43.         OM_None  = 0,
  44.         OM_LeftProtruding    = 1,
  45.         OM_RightProtruding   = 2,
  46.         OM_LeftHangingPunct  = 4,
  47.         OM_RightHangingPunct = 8,
  48.         OM_Default           = OM_RightProtruding + OM_LeftHangingPunct + OM_RightHangingPunct
  49.     };
  50.     enum HyphenationMode {
  51.         NoHyphenation        = 0,
  52.         ManualHyphenation    = 1,
  53.         AutomaticHyphenation = 2
  54.     };
  55.     struct TabRecord
  56.     {
  57.         qreal tabPosition;
  58.         int tabType;
  59.         QChar tabFillChar;
  60.         bool operator==(const TabRecord& other) const {
  61.             return tabPosition==other.tabPosition && tabType==other.tabType && tabFillChar == other.tabFillChar;
  62.         }
  63.         bool operator<(const TabRecord& other)  const { return tabPosition < other.tabPosition; }
  64.         bool operator<=(const TabRecord& other) const { return tabPosition <= other.tabPosition; }
  65.         bool operator>(const TabRecord& other)  const { return tabPosition > other.tabPosition; }
  66.         bool operator>=(const TabRecord& other) const { return tabPosition >= other.tabPosition; }
  67.     };
  68.  
  69.     ParagraphStyle();
  70.     ParagraphStyle(const ParagraphStyle& other);
  71.     ParagraphStyle& operator=(const ParagraphStyle& other);
  72.     ~ParagraphStyle();
  73.  
  74.     static const Xml_string saxxDefaultElem;
  75.     static void  desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, Xml_string elemtag = saxxDefaultElem);
  76.     
  77.     virtual void saxx(SaxHandler& handler, const Xml_string& elemtag) const;
  78.     virtual void saxx(SaxHandler& handler)                     const { saxx(handler, saxxDefaultElem); }
  79.     
  80.  
  81.     void getNamedResources(ResourceCollection& lists) const;
  82.     void replaceNamedResources(ResourceCollection& newNames);
  83.  
  84.     QString displayName() const;
  85.  
  86.     void setContext(const StyleContext* context);
  87.     void update(const StyleContext*);
  88.     
  89.     bool equiv(const Style& other) const;
  90.     
  91.     void applyStyle(const ParagraphStyle& other);
  92.     void eraseStyle(const ParagraphStyle& other);
  93.     void setStyle(const ParagraphStyle& other);
  94.     void erase() { eraseStyle(*this); }
  95.  
  96.     StyleContext* charStyleContext() { return & cstyleContext; }
  97.     const StyleContext* charStyleContext() const { return & cstyleContext; }
  98.     CharStyle & charStyle() { return cstyle; }
  99.     const CharStyle& charStyle() const { return cstyle; }
  100.     /** Normally the context for charStyle() is parentStyle()->charStyleContext()
  101.         Use this method to break that relation and set charStyle()'s context manually
  102.     */
  103.     void breakImplicitCharStyleInheritance(bool val = true);
  104.     /** used internally to establish the implicit relation 
  105.         charStyle().context() == parentStyle()->charStyleContext()
  106.         Done implicitly in setContext(), update(), operator= and breakImplicitCharStyleInheritance()
  107.     */
  108.     void repairImplicitCharStyleInheritance();
  109.     
  110.     /** getter: validates and returns the attribute's value */
  111.     
  112. #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
  113.     attr_TYPE attr_GETTER() const { validate(); return m_##attr_NAME; }
  114. #include "paragraphstyle.attrdefs.cxx"
  115. #undef ATTRDEF
  116.     
  117.     /** setter: sets the attribute's value and clears inherited flag */
  118.     
  119. #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
  120.     void set##attr_NAME(attr_TYPE v) { m_##attr_NAME = v; inh_##attr_NAME = false; }
  121. #include "paragraphstyle.attrdefs.cxx"
  122. #undef ATTRDEF
  123.     void appendTabValue(const TabRecord& tab) { validate(); m_TabValues.append(tab); inh_TabValues = false; }
  124.     
  125.     
  126.     /** setter: resets the attribute's value and sets inherited flag */
  127.     
  128. #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
  129.     void reset##attr_NAME() { m_##attr_NAME = attr_DEFAULT; inh_##attr_NAME = true; }
  130. #include "paragraphstyle.attrdefs.cxx"
  131. #undef ATTRDEF
  132.     
  133.     /** isInherited: returns true if the attriute is inherited */
  134. #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
  135.     bool isInh##attr_NAME() const { return inh_##attr_NAME; }
  136. #include "paragraphstyle.attrdefs.cxx"
  137. #undef ATTRDEF
  138.     
  139.     
  140.     /** isDefined: returns true if the attribute is defined in this style or any parent */
  141. #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
  142.     bool isDef##attr_NAME() const { \
  143.         if ( !inh_##attr_NAME ) return true; \
  144.         const ParagraphStyle * par = dynamic_cast<const ParagraphStyle*>(parentStyle()); \
  145.         return par && par->isDef##attr_NAME(); \
  146.     }
  147. #include "paragraphstyle.attrdefs.cxx"
  148. #undef ATTRDEF
  149.     
  150.     
  151. private:
  152.         
  153.     // member declarations:
  154.     StyleContextProxy cstyleContext;
  155.     bool cstyleContextIsInh;
  156.     CharStyle cstyle;
  157.     
  158. #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
  159.         attr_TYPE m_##attr_NAME; \
  160.             bool inh_##attr_NAME;
  161. #include "paragraphstyle.attrdefs.cxx"
  162. #undef ATTRDEF
  163.         
  164. };
  165.  
  166. #endif
  167.